package cn.hospital.controller;

import cn.hospital.service.DropDownBoxQueryService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

/**
 * 下拉框查询
 */
@RestController
@RequestMapping("/DropDownBoxQuery")
public class DropDownBoxQueryController {
    @Resource
    private DropDownBoxQueryService dropDownBoxQueryService;

    /**
     * 查询职位
     *
     * @return
     */
    @ResponseBody
    @RequestMapping("/findRole")
    public Map<String, Object> findRole() {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("roleList", dropDownBoxQueryService.findRole());
        return map;
    }

    /**
     * 查询医院科室
     *
     * @return
     */
    @ResponseBody
    @RequestMapping("/findHospitalDempartment")
    public Map<String, Object> findHospitalDempartment() {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("hospitalList", dropDownBoxQueryService.findHospital());
        map.put("departmentList", dropDownBoxQueryService.findDeparment());
        return map;
    }

    /**
     * 根据医院id查询医院下的科室
     *
     * @param session 从session中获取登录人所属的科室
     * @return
     */
    @RequestMapping("/findByhospitalId")
    public Map<String, Object> findByhospitalId(HttpSession session) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("departmentList", dropDownBoxQueryService.findByhospitalId(session));
        return map;
    }

    /**
     * 查询随访组信息
     *
     * @return
     */
    @RequestMapping("/findByGrouptable")
    public Map<String, Object> findByGrouptable() {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("grouptableList", dropDownBoxQueryService.findByGrouptable());
        return map;
    }

    /**
     * 查询民族
     *
     * @return
     */
    @RequestMapping("/findNational")
    public Map<String, Object> findNational() {
        Map<String, Object> map = new HashMap<>();
        map.put("nationalList", dropDownBoxQueryService.findNational());
        return map;
    }

    /**
     * 查询省市县
     *
     * @return
     */
    @RequestMapping("/findAddress")
    public Map<String, Object> findAddress() {
        return dropDownBoxQueryService.findAddress();
    }

    /**
     * 查询病区、楼层、房间、床位
     *
     * @return
     */
    @RequestMapping("/findWard")
    public Map<String, Object> findWard() {
        return dropDownBoxQueryService.findWard();
    }
}
